package com.chinasoft;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

public class PlayView extends JFrame {
    // contentPane用于存放界面中的各种组件
    JFrame start_frame = new JFrame();
    JPanel contentPane = new JPanel();
    GamePanel bgPanel = new GamePanel();


    public PlayView() {
        start_frame.add(contentPane);
        // 设置窗口标题
        setTitle("第一关");
        // 设置窗口的位置和大小
        setBounds(200, 20, 1200, 1060);
        // 设置窗口关闭操作，当关闭窗口时退出程序
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // 显示窗口
        setVisible(true);
        // 为内容面板设置边框
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        // 将内容面板设置为窗口的ContentPane
        setContentPane(contentPane);
        // 设置内容面板的布局为绝对布局
        contentPane.setLayout(null);

        // 关卡背景区域
        bgPanel.initBases();
        contentPane.add(bgPanel);

        // 按钮区域
        JPanel buttonPanel = new JPanel();
        buttonPanel.setBounds(1000, 0, 200, 1000);
        buttonPanel.setBackground(Color.LIGHT_GRAY);
        buttonPanel.setLayout(null);
        buttonPanel.setFont(new Font("微软雅黑", Font.BOLD, 20));
        contentPane.add(buttonPanel);

        // 设置按钮
        // 重来
        JButton again_button = new JButton("重来");
        again_button.setBounds(40, 200, 100, 30);
        again_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(again_button);
        // 实例化
        ButtonMenu buttonMenu = new ButtonMenu();
        ButtonMenu.ReplayButtonAdapter replayButtonAdapter = buttonMenu.new ReplayButtonAdapter(bgPanel);
        again_button.addMouseListener(replayButtonAdapter);

        // 第一关
        JButton first_guanka_button = new JButton("第一关");
        first_guanka_button.setBounds(40, 300, 100, 30);
        first_guanka_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(first_guanka_button);

        // 实例化
        ButtonMenu.StartButtonAdapter startButtonAdapter = buttonMenu.new StartButtonAdapter(this);
        first_guanka_button.addMouseListener(startButtonAdapter);

        // 上一关
        JButton pre_guanka_button = new JButton("上一关");
        pre_guanka_button.setBounds(40, 400, 100, 30);
        pre_guanka_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(pre_guanka_button);
        ButtonMenu.PrevButtonAdapter prevButtonAdapter = buttonMenu.new PrevButtonAdapter(bgPanel);
        pre_guanka_button.addMouseListener(prevButtonAdapter);

        // 下一关
        JButton next_guanka_button = new JButton("下一关");
        next_guanka_button.setBounds(40, 500, 100, 30);
        next_guanka_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(next_guanka_button);
        ButtonMenu.NEXTButtonAdapter nextButtonAdapter = buttonMenu.new NEXTButtonAdapter(bgPanel);
        next_guanka_button.addMouseListener(nextButtonAdapter);

        // 最终关
        JButton final_guanka_button = new JButton("最终关");
        final_guanka_button.setBounds(40, 600, 100, 30);
        final_guanka_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(final_guanka_button);
        ButtonMenu.LastButtonAdapter lastButtonAdapter = buttonMenu.new LastButtonAdapter(bgPanel);
        final_guanka_button.addMouseListener(lastButtonAdapter);

        // 音乐
        JButton music_button = new JButton("音乐");
        music_button.setBounds(40, 700, 100, 30);
        music_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(music_button);
        // 鼠标监听未实现

        // 退出
        JButton exit_button = new JButton("退出");
        exit_button.setBounds(40, 800, 100, 30);
        exit_button.setFont(new Font("微软雅黑", Font.BOLD, 20));
        buttonPanel.add(exit_button);
        ButtonMenu.ExitButtonAdapter exitButtonAdapter = buttonMenu.new ExitButtonAdapter();
        exit_button.addMouseListener(exitButtonAdapter);

    }


}
